import 'package:encrypt/encrypt.dart';

class AESUtil {
  // that.encryptedString.key 1234567890adbcde
  // Login.vue?7463:285 that.encryptedString.iv 1234567890hjlkew

  static String generateAESencry(String data) {
    final plainText = data;
    final key = Key.fromUtf8("1234567890adbcde");
    // final key = Key.fromUtf8(keyStr);
    // final iv = IV.fromUtf8(ivStr);
    final iv = IV.fromUtf8("1234567890hjlkew");
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
    final encrypted = encrypter.encrypt(plainText, iv: iv);
    print(encrypted.base64); // R4PxiU3h8YoIRq
    return encrypted.base64;
  }

  static String generateAESdecry(String data) {
    final plainText = data;
    final key = Key.fromUtf8("1234567890adbcde");
    // final key = Key.fromUtf8(keyStr);
    // final iv = IV.fromUtf8(ivStr);
    final iv = IV.fromUtf8("1234567890hjlkew");
    final encrypter = Encrypter(AES(key, mode: AESMode.cbc));
   final decrypted = encrypter.decrypt64(plainText, iv: iv);
    return decrypted;
  }
}